using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using LeadTracker.Models;

namespace LeadTracker.Models.MSTest
{
	
	public partial class EditorCollectionTests
	{


        

		[TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_Add ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            var oldCount = objectUnderTest.Count;
            LeadTracker.Models.EditorModel newItem;

            try
            {
                newItem = new LeadTracker.Models.EditorModel();
                objectUnderTest.Add(newItem);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(oldCount + 1, objectUnderTest.Count);
            Assert.IsTrue(objectUnderTest.Contains(newItem));

		}

		[TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_AddClear ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            LeadTracker.Models.EditorModel newItem;
            
            try
            {
                newItem = new LeadTracker.Models.EditorModel();
                objectUnderTest.Add(newItem);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            
            Assert.IsTrue(objectUnderTest.Contains(newItem));

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);
            Assert.IsFalse(objectUnderTest.Contains(newItem));

		}

		[TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_Clear ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;         

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

		}


        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_AddRemove ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            var oldCount = objectUnderTest.Count;
            
            LeadTracker.Models.EditorModel newItem;

            try
            {
                newItem = new LeadTracker.Models.EditorModel();
                objectUnderTest.Add(newItem);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(oldCount + 1, objectUnderTest.Count);
            Assert.IsTrue(objectUnderTest.Contains(newItem));

            objectUnderTest.Remove(newItem);
            
            Assert.AreEqual(oldCount, objectUnderTest.Count);
            Assert.IsFalse(objectUnderTest.Contains(newItem));
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_AddRemoveAt ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            var oldCount = objectUnderTest.Count;
            LeadTracker.Models.EditorModel newItem;

            try
            {
                newItem = new LeadTracker.Models.EditorModel();
                objectUnderTest.Add(newItem);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(oldCount + 1, objectUnderTest.Count);
            Assert.IsTrue(objectUnderTest.Contains(newItem));

            var newIndex = objectUnderTest.IndexOf(newItem);
            objectUnderTest.RemoveAt(newIndex);
            
            Assert.AreEqual(oldCount, objectUnderTest.Count);
            Assert.IsFalse(objectUnderTest.Contains(newItem));
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_InsertFirst ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            var testItem = new LeadTracker.Models.EditorModel();
            objectUnderTest.Insert(0, testItem);

            Assert.AreEqual(4, objectUnderTest.Count);
            Assert.AreEqual(0, objectUnderTest.IndexOf(testItem));                     
            Assert.IsTrue(objectUnderTest.Contains(testItem));
            
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_InsertMiddle ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            var testItem = new LeadTracker.Models.EditorModel();
            objectUnderTest.Insert(2, testItem);

            Assert.AreEqual(4, objectUnderTest.Count);
            Assert.AreEqual(2, objectUnderTest.IndexOf(testItem));                     
            Assert.IsTrue(objectUnderTest.Contains(testItem));
            
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_InsertLast ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            var testItem = new LeadTracker.Models.EditorModel();
            objectUnderTest.Insert(3, testItem);

            Assert.AreEqual(4, objectUnderTest.Count);
            Assert.AreEqual(3, objectUnderTest.IndexOf(testItem));                     
            Assert.IsTrue(objectUnderTest.Contains(testItem));
            
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_CopyTo_Middle ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            var array = new LeadTracker.Models.EditorModel[5];

            objectUnderTest.CopyTo(array, 1);

            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[0]);
            Assert.AreEqual(newItem1, array[1]);
            Assert.AreEqual(newItem2, array[2]);
            Assert.AreEqual(newItem3, array[3]);
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[4]);
            
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_CopyTo_Front ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            var array = new LeadTracker.Models.EditorModel[5];

            objectUnderTest.CopyTo(array, 0);

            Assert.AreEqual(newItem1, array[0]);
            Assert.AreEqual(newItem2, array[1]);
            Assert.AreEqual(newItem3, array[2]);
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[3]);
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[4]);
            
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_CopyTo_End ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            var array = new LeadTracker.Models.EditorModel[5];

            objectUnderTest.CopyTo(array, 2);

            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[0]);
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[1]);
            Assert.AreEqual(newItem1, array[2]);
            Assert.AreEqual(newItem2, array[3]);
            Assert.AreEqual(newItem3, array[4]);            
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_CopyTo_Full ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            var array = new LeadTracker.Models.EditorModel[3];

            objectUnderTest.CopyTo(array, 0);

            Assert.AreEqual(newItem1, array[0]);
            Assert.AreEqual(newItem2, array[1]);
            Assert.AreEqual(newItem3, array[2]);
            
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_CopyTo_TooSmall ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            var array = new LeadTracker.Models.EditorModel[2];

            try
            {
                objectUnderTest.CopyTo(array, 0);
                Assert.Fail("This should have thrown an exception.");
            }
            catch (ArgumentException)
            {
                //OK
            }

            //make sure nothing was over-written
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[0]);
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[1]);
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_CopyTo_PastEnd ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            var array = new LeadTracker.Models.EditorModel[3];

            try
            {
                objectUnderTest.CopyTo(array, 1);
                Assert.Fail("This should have thrown an exception");
            }
            catch (ArgumentException)
            {
                //OK
            }

            //make sure nothing was over-written
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[0]);
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[1]);
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[2]);

		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_CopyTo_OOR ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            var array = new LeadTracker.Models.EditorModel[3];

            try
            {
                objectUnderTest.CopyTo(array, -1);
                Assert.Fail("This should have thrown an exception.");
            }
            catch (ArgumentOutOfRangeException)
            {
                //OK
            }

            //make sure nothing was over-written
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[0]);
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[1]);
            Assert.AreEqual(default(LeadTracker.Models.EditorModel), array[2]);
            
            
		}

        [TestMethod]
        public void EditorCollectionTests_ListT_EditorModel_CopyTo_Null ()
		{
			IList<LeadTracker.Models.EditorModel> objectUnderTest = CreateObject();

			if (objectUnderTest.IsReadOnly)
                return;

            objectUnderTest.Clear();
            Assert.AreEqual(0, objectUnderTest.Count);

            LeadTracker.Models.EditorModel newItem1;
            LeadTracker.Models.EditorModel newItem2;
            LeadTracker.Models.EditorModel newItem3;

            try
            {
                newItem1 = new LeadTracker.Models.EditorModel();
                newItem2 = new LeadTracker.Models.EditorModel();
                newItem3 = new LeadTracker.Models.EditorModel();

                objectUnderTest.Add(newItem1);
                objectUnderTest.Add(newItem2);
                objectUnderTest.Add(newItem3);
            }
            catch (ArgumentException)
            {
                //OK
                return;
            }            

            Assert.AreEqual(3, objectUnderTest.Count);

            try
            {
                objectUnderTest.CopyTo(null, -1);
                Assert.Fail("This should have thrown an exception.");
            }
            catch (ArgumentNullException)
            {
                //OK
            }

		}




        
	}
}

